#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Unit.h>
#include <Metrology.h>
#include <Cubage.h>
#include <FormatOutput.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(CubageDisplay)
{
    TEST( 1 oz should be displayed to 6 tsp)
    {
        std::ostringstream buf;
        Cubage(1, OZ).output(buf, BASICUNITOUTPUT);
        ASSERT_TRUE(buf.str() == "6 tsp");
    }

    TEST( 2 tbsp should be displayed to 6 tsp)
    {
        std::ostringstream buf;
        Cubage(2, TBSP).output(buf, BASICUNITOUTPUT);
        ASSERT_TRUE(buf.str() == "6 tsp");
    }


    TEST( 0 oz should be displayed to 0 tsp)
    {
        std::ostringstream buf;
        Cubage(0, OZ).output(buf, BASICUNITOUTPUT);
        ASSERT_TRUE(buf.str() == "0 tsp");
    }

    TEST( 1 tbsp should be displayed to 1 tbsp)
    {
        std::ostringstream buf;
        Cubage(1, TBSP).output(buf, STDOUTPUT);
        ASSERT_TRUE(buf.str() == "1 tbsp");
    }

    TEST( 5 tsp should be displayed to 1 tbsp 2 tsp)
    {
        std::ostringstream buf;
        Cubage(5, TSP).output(buf, STDOUTPUT);
        ASSERT_TRUE(buf.str() == "1 tbsp 2 tsp");
    }


    TEST( 11 tsp should be displayed to 1 oz 1 tbsp 2 tsp)
    {
        std::ostringstream buf;
        Cubage(11, TSP).output(buf, STDOUTPUT);
        ASSERT_TRUE(buf.str() == "1 oz 1 tbsp 2 tsp");
  }


};


FIXTURE(CubageCompare)
{

    TEST(1 oz should be equal to 2 tbsp)
    {
        Cubage oz(1, OZ);
        Cubage tbsp(2, TBSP);
        ASSERT_TRUE(oz == tbsp);
    }

    TEST(1 oz should be not equal to 3 tbsp)
    {
        Cubage oz(1, OZ);
        Cubage tbsp(3, TBSP);
        ASSERT_TRUE(oz != tbsp);
    }

    TEST(1 tbsp should be equal to 3 tsp)
    {
        Cubage tsp(3, TSP);
        Cubage tbsp(1, TBSP);
        ASSERT_TRUE(tsp == tbsp);
    }

    TEST(2 tbsp should be not equal to 7 tsp)
    {
        Cubage tsp(7, TSP);
        Cubage tbsp(2, TBSP);
        ASSERT_TRUE(tsp != tbsp);
    }
};

FIXTURE(CubageCalc)
{
    TEST(1 oz == 1 tbsp + 3 tsp)
    {
        Cubage tbsp(1, TBSP);
        Cubage tsp(3, TSP);
        Cubage oz(1, OZ);

        ASSERT_TRUE(oz == (tbsp + tsp));
    }

    TEST(71 tsp == 1 oz + 20 tbsp + 5 tsp)
    {
        Cubage tbsp(20, TBSP);
        Cubage oz(1, OZ);
        Cubage tspA(5, TSP);
        Cubage tspB(71, TSP);

        ASSERT_TRUE(tspB == (oz + tbsp + tspA));
    }


    TEST(2 oz != 1 oz + 20 tbsp)
    {
        Cubage tbsp(20, TBSP);
        Cubage ozA(1, OZ);
        Cubage ozB(2, OZ);

        ASSERT_TRUE(ozB != (ozA + tbsp));
    }

};


